package workexp.alg.question;

public class RotateImage {

    /**
     * 旋转90度
     * @param matrix
     */
    public void rotate(int[][] matrix) {
        int len = matrix.length;
        for(int i=0;i<len/2;i++){
            //i:x,j:y,从
            for(int j=i;j<len-1-i;j++){
                int tmp = matrix[i][j];
                //内循环
                int m = len-1-j;
                //外循环标记
                int n = len-1-i;

                matrix[i][j]=matrix[m][i];
                matrix[m][i]=matrix[n][m];
                matrix[n][m]=matrix[j][n];
                matrix[j][n]=tmp;

            }

        }
    }
}
